﻿using System.Windows;
using System;
using System.Windows.Forms;
using PluginMediatorSample;

namespace PluginMediatorSample.Classes
{
    /// <summary>
    /// Simple ViewModel that registers to a message from the Mediator
    /// This ViewModel demos the Attribute based registration 
    /// </summary>
    class A : BaseViewModel
    {
        public A()
        {
            Mediator.Register<Test1Delegate>(this, "message", Test1);
            MessageBox.Show(string.Format("+ {0}", typeof(A).Name));
        }

        private void Test1(SomeData1 data)
        {
            MessageBox.Show(string.Format("{0} : {1}", typeof(A).Name, data.Text));
        }

        ~A()
        {
            Mediator.Unregister<Test1Delegate>(this, "message", Test1);
            MessageBox.Show(string.Format("- {0}", typeof(A).Name));
        }
    }
}